package com.zto.sch.advance.dubbo.泛化调用;

import com.alibaba.dubbo.rpc.RpcContext;
import com.zto.sch.base.util.JsonUtil;

public class GreetingServiceImpl implements GreetingService {

    @Override
    public String sayHello(String name) {

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "Hello " + name + " " + RpcContext.getContext().getAttachment("company");
    }

    @Override
    public Result<String> testGeneric(PoJo poJo) {

        Result<String> result = new Result<>();
        result.setSucess(true);
        try {
            result.setData(JsonUtil.toJSON(poJo));
        } catch (Exception e) {
            e.printStackTrace();
        }

        return result;
    }
}